package com.abocode.aichat.server.modules.protocol.handler;

import com.abocode.aichat.server.channel.ChannelWrapper;
import com.abocode.aichat.server.context.ServerRuntimeContext;
import com.abocode.aichat.server.entity.Entity;
import com.abocode.aichat.server.entity.EntityImpl;
import com.abocode.aichat.server.modules.ModuleHandler;
import com.abocode.aichat.server.reply.Replies;
import com.abocode.aichat.server.stanza.Stanza;
import com.abocode.aichat.server.stanza.StanzaWrapper;
import com.abocode.aichat.server.channel.ChannelWrapper;
import com.abocode.aichat.server.context.ServerRuntimeContext;
import com.abocode.aichat.server.entity.Entity;
import com.abocode.aichat.server.entity.EntityImpl;
import com.abocode.aichat.server.reply.Replies;
import com.abocode.aichat.server.stanza.Stanza;
import io.netty.channel.Channel;

import java.util.List;
import java.util.Map;

/**
 * Created by franky.
 */
public class ChatOfflineHandler implements ModuleHandler {
    public Replies execute(ChannelWrapper channelWrapper, Stanza stanza, ServerRuntimeContext serverRuntimeContext) {
        Map body=stanza.body();
        String jid = String.valueOf(body.get("jid"));
        Entity jidEntity = EntityImpl.parse(jid);
        return serverRuntimeContext.getMessageGatewayPipeline().messages(channelWrapper.getChannel(),jidEntity);
    }

    public String module() {
        return "offline";
    }
}
